package com.dfrz.planeclub.config;


import com.dfrz.planeclub.interceptor.AuthorityInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.Arrays;
import java.util.List;

/**
 * @author PuXiaLing
 * @description: TODO
 * @date 2024/3/27 22:36
 */
@Configuration
public class MyMvcConfig implements WebMvcConfigurer {

    private static final List<String> EXCLUDE_PATH= Arrays.asList("/","css/**","js/**","imgs/**","json/**","font/**","*.html","/login");
    @Bean
    public AuthorityInterceptor authorityInterceptor(){
        return new AuthorityInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authorityInterceptor())
                .addPathPatterns("/getUserInfo")
                .excludePathPatterns(EXCLUDE_PATH);
    }
}
